package com.ziq.zcamp.api.service

import android.widget.Toast
import com.ziq.base.manager.RetrofitManager
import com.ziq.zcamp.manager.GlobalContextManager
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent


//网络请求服务
@Module
@InstallIn(SingletonComponent::class)
class ServiceModule {

    companion object {
        fun onApiFail(it: String){
            if (it.isNotEmpty()){
                Toast.makeText(GlobalContextManager.appContext, it, Toast.LENGTH_SHORT).show()
            }
        }
    }

    @Provides
    fun provideCommonService(retrofitManager : RetrofitManager): CommonService {
        return retrofitManager.getRetrofit(BASE_URL)!!.create(CommonService::class.java)
    }

    @Provides
    fun provideUserAccountService(retrofitManager : RetrofitManager): UserAccountService {
        return retrofitManager.getRetrofit(BASE_URL)!!.create(UserAccountService::class.java)
    }

    @Provides
    fun provideCampService(retrofitManager : RetrofitManager): CampService {
        return retrofitManager.getRetrofit(BASE_URL)!!.create(CampService::class.java)
    }

    @Provides
    fun provideActivityService(retrofitManager : RetrofitManager): ActivityService {
        return retrofitManager.getRetrofit(BASE_URL)!!.create(ActivityService::class.java)
    }

    @Provides
    fun provideMerchantService(retrofitManager : RetrofitManager): MerchantService {
        return retrofitManager.getRetrofit(BASE_URL)!!.create(MerchantService::class.java)
    }

    @Provides
    fun providePostingService(retrofitManager : RetrofitManager): PostingService {
        return retrofitManager.getRetrofit(BASE_URL)!!.create(PostingService::class.java)
    }


}